package com.demo.lock8;

import java.util.concurrent.TimeUnit;

public class Test1 {
    public static void main(String[] args) {
        Phone phone = new Phone();
        new Thread(()->{
            phone.send();
        },"A").start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(()->{
            phone.call();
        },"A").start();
    }
}
class Phone{
    /**
     * 队列 + 锁
     * synchronized 锁的是方法的调用者
     */
    public synchronized void send(){
        System.out.println("发短信");
    }
    public synchronized void call(){
        System.out.println("打电话");
    }

}
